<?php


namespace core\entity;

use core\lib\BotAPI;

/**
 * 基础用户
 * Class User
 * @package core\entity
 */
class User {

    /**
     * @var int
     */
    public $id;

    /**
     * @var string
     */
    public $nickname;

    /**
     * @var string
     */
    public $sex;

    /**
     * @var int
     */
    public $age;

    /**
     * 发送消息
     * @param string ...$message
     * @return Message
     */
    public function sendMessage(...$message): Message {
        $r_message = implode('', $message);
        return new Message([
            'message_id' => bot()->sendPrivateMessage($this->id, $r_message),
            'raw_message' => $r_message,
            'message' => $r_message,
        ]);
    }

    public function sendLike($times) {
        bot()->sendLike($this->id, $times);
    }

    public function __construct($sender) {
        $this->id = $sender['user_id'];
        $this->nickname = $sender['nickname'];
        $this->sex = $sender['sex'];
        $this->age = $sender['age'];
    }

}
